package cn.fsd.dto;

import cn.fsd.domain.Order;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.UUID;

@AllArgsConstructor
@NoArgsConstructor
public class OrderDTO {
    private String commodity_id;
    private String customer_id;

    private String order_type;
    private String operator_id;
    private AddOrderForm orderForm;

    public String getCommodity_id() {
        return commodity_id;
    }

    public void setCommodity_id(String commodity_id) {
        this.commodity_id = commodity_id;
    }

    public String getCustomer_id() {
        return customer_id;
    }

    public void setCustomer_id(String customer_id) {
        this.customer_id = customer_id;
    }

    public String getOrder_type() {
        return order_type;
    }

    public void setOrder_type(String order_type) {
        this.order_type = order_type;
    }

    public String getOperator_id() {
        return operator_id;
    }

    public void setOperator_id(String operator_id) {
        this.operator_id = operator_id;
    }

    public AddOrderForm getOrderForm() {
        return orderForm;
    }

    public void setOrderForm(AddOrderForm orderForm) {
        this.orderForm = orderForm;
    }

    public Order DTO2Order(){
        Order order=new Order();
        order.setCustomer_id(customer_id);
        order.setOrder_id(String.valueOf(UUID.randomUUID()));
        order.setOrder_date(new Date());
        order.setOrder_status("初始状态");
        order.setOrder_type(order_type);
        order.setAddress_choice(orderForm.getAddress_choice());
        order.setCommodity_id(commodity_id);
        order.setCommodity_num(orderForm.getCommodity_num());
        order.setDelivery_date(orderForm.getDelivery_date());
        order.setIs_invoice(orderForm.getIs_invoice());
        order.setOrder_total_amount(orderForm.getOrder_total_amount());
        order.setNote(orderForm.getNote());
        order.setDelivery_status("初始状态");
        order.setOperator_id(operator_id);

        return order;
    }
}
